package com.twh.www.service;

import com.twh.www.entity.WnUser;
import com.twh.www.service.login.LoginStrategy;
import com.twh.www.service.login.LoginStrategyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 登录服务类
 */
@Service
public class LoginService {
    @Autowired
    private LoginStrategyFactory strategyFactory;

    /**
     * 用户登录
     * @param loginType 登录类型（PASSWORD/PHONE/EMAIL）
     * @param credentials 登录凭证
     * @return 用户对象，登录失败返回null
     */
    public WnUser login(String loginType, Object... credentials) {
        LoginStrategy strategy = strategyFactory.getStrategy(loginType);
        if (strategy == null) {
            return null;
        }
        return strategy.login(credentials);
    }
} 